package cate.game.pvp.guildwar;

import cate.game.framework.ModuleMan;
import cate.game.pvp.guildwar.data.GWInnerMsg;
import cate.game.pvp.guildwar.data.msg.GWBaseInnerResp;
import cate.game.pvp.guildwar.data.msg.GWTopGuildRwdReq;
import cate.game.pvp.guildwar.data.msg.GWSideApplyInnerReq;
import cate.game.pvp.guildwar.data.msg.GWSideInnerUpdate;
import cp.solution.rpc.RpcMsgHead;
import easy.java.dev.note.NoteClass;

@NoteClass("公会战-Game接收消息模块")
public class GWGameReceiveModule extends ModuleMan {

    @Override
    public void initDependent() throws Exception {
        game.rpcRecv().onFireAndForgetTemplate(GWInnerMsg.GAME_CONNECT_BACK, GWBaseInnerResp.class, this::onGameConnectBack);
        game.rpcRecv().onFireAndForgetTemplate(GWInnerMsg.CROSS_BASE, GWBaseInnerResp.class, this::handleBase);
        game.rpcRecv().onFireAndForgetTemplate(GWInnerMsg.G2G_APPLY_SIDE, GWSideApplyInnerReq.class, this::handSideApply);
        game.rpcRecv().onFireAndForgetTemplate(GWInnerMsg.G2G_SIDE_UPDATE, GWSideInnerUpdate.class, this::handleSideUpdate);
        game.rpcRecv().onFireAndForgetTemplate(GWInnerMsg.CROSS_TOP_RWD, GWTopGuildRwdReq.class, this::handleGuildRwd);
    }

    public void onGameConnectBack(RpcMsgHead head, GWBaseInnerResp resp) {
        game.pvp.guildWar.getDataManager().updateBase(resp);
    }

    public void handleBase(RpcMsgHead head, GWBaseInnerResp resp) {
        game.pvp.guildWar.getDataManager().updateBase(resp);
    }

    public void handSideApply(RpcMsgHead head, GWSideApplyInnerReq req){
        game.pvp.guildWar.getDataManager().handleSideApply(req);
    }

    public void handleSideUpdate(RpcMsgHead head, GWSideInnerUpdate data){
        game.pvp.guildWar.getDataManager().handleSideUpdate(data);
    }

    public void handleGuildRwd(RpcMsgHead head, GWTopGuildRwdReq req){
        game.pvp.guildWar.getDataManager().handleTopGuildRwd(req);
    }
}
